Skip to content

Adds device_index and bind_device_by_index to android and linux #573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ningyuan-wang
Copy link

This PR adds device_index and bind_device_by_index to android and linux OS. This allows the sockets to bind to the interface index directly, and checks the interface index bonded to.

libc version is bumped to `0.2.172' as it is the first version SO_BINDTOIFINDEX is defined for Android.

Fixes #569

@ningyuan-wang
Copy link
Author

The PR is updated to fix the failed formatting check.

@ningyuan-wang
Copy link
Author

Commit is updated to also include fuchsia as target OS, since

  1. this matches the build target of bind_device.
  2. libc support for SO_BINDTOIFINDEX is available for fuchsia.

Copy link
Collaborator

@Darksonn Darksonn May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea: Should we let the v4/v6 methods also exist on Linux and just have them call bind_device_by_index? That way, it's easier to write code that supports both cases.

Thoughts @Thomasdezeeuw ?

This commit adds bind_device_by_index to android, fuchsia, and linux OS.
This binds socket to a particular interface similarly to bind_device
except that the interfaces are referenced by its index rather than name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Socket::bind_device_by_index_{v4,v6} should be available on linux and android
2 participants